from selenium import webdriver
from selenium.webdriver.common.by import By
import time

class  LoginOperation:

    def  login(self,driver,name,pwd):
        time.sleep(2)
        driver.find_element(By.XPATH,'//*[@id="username"]').send_keys(name)

        driver.find_element(By.XPATH,'//*[@id="password"]').send_keys(pwd)

        driver.find_element(By.XPATH, '//*[@id="login_btn"]').click()
        time.sleep(2)


    def  getSuccessResult(self,driver):
        return driver.find_element(By.XPATH,'//*[@id="logo"]/a').text


    def  getNameErrorResult(self,driver):
        return driver.find_element(By.XPATH,'/html/body/div/div/div/form/div[1]/span[1]').text


    def getPwdErrorResult(self, driver):
        return driver.find_element(By.XPATH, '/html/body/div/div/div/form/div[2]/span[1]').text